<?php
namespace Admin\Model;
use Think\Model;

class CategoryModel extends Model
{
	protected $_validate = array(
		array('chinese_name','require','中文语言名称必须！'),
		array('english_name', 'require', '英文名称必须'),
	);

    public function getCatInfo($id)
    {
        return $this->find($id);
    }
	
	public function getCategoryList($parent_id) {
		$parent_id = (int)$parent_id;
		$menus = M('Category')->where('parent_id = ' . $parent_id . ' and is_on = 1')->order('list_order asc, id asc')->select();	
		return $menus;	
	}
	
	/**
	 * 当前导航
	 */
	public function getCurrentPos($menu_id)
	{
		$res = M('Category')->where('id = ' . $menu_id . ' and is_on = 1')->find();
		$str = '';
		if ($res['parent_id']) {
			$str .= $this->getCurrentPos($res['parent_id']);
		}
		return $str . $res['chinese_name'] . ' > ';
	}
}